// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import './store/overridestorage'
import './store/clearstorage'
import Vue from 'vue'
import 'babel-polyfill'
import App from './App'
import axios from './http'
// import axios2 from './http2'
import store from './store/store'
import router from './router'
import ElementUI from 'element-ui'
import './element-variables.scss'
import * as myjs from './js/myjs.js'
import IdleService from './util/idleService'

const idleService = new IdleService()

idleService.onTimeout(() => {
  // 显示超时提示
  console.log('倒计时触发弹出倒计时窗口')
  store.dispatch('showIdleWarning', true)
  // localStorage.setItem('idleTimeout', true)
})

// idleService.onExpired(() => {
//   // 强制退出
//   store.dispatch('logout')
//   console.log('退出触发弹出倒计时窗口')
//   // store.dispatch('showIdleWarning', true)
//   // router.push('/login')
// })

// 导出以便在组件中使用
Vue.prototype.$idleService = idleService

// import 'element-ui/lib/theme-chalk/index.css'
// import './assets/icon/iconfont.css'
console.log('main加载')
// 引入基本模板
let echarts = require('echarts/lib/echarts')
// 引入折线图
require('echarts/lib/chart/line')
// 引入柱状图组件
require('echarts/lib/chart/bar')
// 引入饼状图组件
require('echarts/lib/chart/pie')
// 引入提示框和title组件，图例
require('echarts/lib/component/tooltip')
require('echarts/lib/component/title')
require('echarts/lib/component/legend')
require('echarts/lib/component/toolbox')
// 引入雷达图组件
require('echarts/lib/chart/radar')
// require('echarts/lib/component/markLine')
// require('echarts/lib/component/dataZoom')
// eslint-disable-next-line no-undef
Vue.prototype.$echarts = echarts
// 引入组件

// eslint-disable-next-line no-undef
Vue.config.productionTip = false
// eslint-disable-next-line no-undef
Vue.use(ElementUI)

// 将axios挂载到prototype上，在组件中可以直接使用this.$http访问

Vue.prototype.$http = axios
// Vue.prototype.$http.defaults.timeout = 120000
// Vue.prototype.$http2 = axios2
Vue.prototype.$store = store
Vue.prototype.$therouter = router
Vue.prototype.MyGetDateStr = myjs.GetyyyyMMdd
Vue.prototype.MyDownloadfile = myjs.Downloadfile
Vue.prototype.text2month = myjs.text2month
Vue.prototype.int2sf = myjs.int2sf
Vue.prototype.dateFtt = myjs.dateFtt
// 引入mockjs
require('./mock.js')

/* eslint-disable no-new */
new Vue({
  el: '#app',
  axios,
  // axios2,
  router,
  store,
  render: h => h(App)
  // components: { App },
  // template: '<App/>'
})
